package cn.bdqn.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * @author 小涛
 * @date: 2020/6/24 16:56
 */
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {



    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/login.html").setViewName("login");
        registry.addViewController("/main.html").setViewName("index.html");
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //请求
        registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**").excludePathPatterns("/login.html",
                "/captcha","/verifyCaptcha","/forgotPwd.html","/forgotPwdSuccess.html","/resetPassword.html","/resetPasswordSuccess.html",
                "/forgotPwdUI","/forgotPwd","/resetPassword","/resetPasswordUI","/util/*","/util/EmailUtls/*","/util/GenerateLinkUtils/*",
                "/","/loginTo","/login","/css/*","/css/js/**","/css/img/**","/css/bootstrap/**","/css/fonts/**","/css/public/**","/css/webfonts/**","/weixinlogin");
    }
}
